package com.HW.Search;

import sun.java2d.pipe.AAShapePipe;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @ClassName : TSplitApple
 * @Author : kele
 * @Date: 2023/11/5 12:42
 * @Description :
 */
public class TSplitApple {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }

        handle(arr);

    }

    public static void handle(int[] array) {

        Arrays.sort(array);

        if (planA(array)) {
            int B = 0;
            for (int i = 1; i < array.length; i++) {
                B += array[i];
            }
            System.out.println(B);
        } else {
            System.out.println("-1");
        }


    }


    public static boolean planA(int[] array) {

        int res = array[0];
        for (int i = 1; i < array.length; i++) {
            res ^= array[i];
        }
        return res == 0;

    }
}
